#include "../include/data.h"
#include <memory.h>
void data::ass(string source)
{
    memset(message,0,sizeof(message));
   if(source.length() > sizeof(message))
   {

    for(unsigned int i = 0 ;i< sizeof(message);i++)
    {
            this->message[i] = source[i];
    }
   }
   else
   {
        for(unsigned int i = 0 ;i<source.length();i++)
        {
              this->message[i] = source[i];
        }
   }


}
void data::printmessage()
{
    cout<<"Type : "<<this->gettype()<<" X : "<<this->getx()<<"  Y : "<<this->gety()<<" Message : "<<this->getmessage()<<endl;
}
void data::setvalue(int type,int x,int y,string mes)
{
	//DATA a;
	this->type  = type;
	this->x = x;
	this->y = y;
	this->ass(mes);
	//return a;

}
string data::getmessage()
{
    string s="";
    for(unsigned int i=0 ;i<sizeof(message);i++)
    {
        if(message[i] == 0)
        {
            return s;
        }
        else
        {
            s += message[i];
        }
    }
     return  s;

}
int data::getx()
{

    return this->x;
}
int data::gety()
{
    return this->y;
}
int data::gettype()
{

    return this->type;
}

data::data()
{
    this->type = -1;
    this->x = -1;
    this->y = -1;
    //this->message = NULL;
}

data::~data()
{
   this->type = -1;
    this->x = -1;
    this->y = -1;
   //this->message = NULL;
}
